package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:内部类的实例化三种方法:inner1,inner2,inner3
 * User: LianBao
 * Date: 2024-03-15
 * Time: 17:18
 */

/**
 * 你需要记住的就是:如果一个类是外部类的成员,也就是说在使用成员内部类时,需借助外部类的对象来创建内部类的对象就好了
 */
class OuterClass {

    public static int a = 10;
    public int b = 20;

    public void Fun() {

    }

    public static void staticFun() {

    }


    //静态内部类
    static class InnerClass {

        public void fun2() {
            System.out.println(a);
            System.out.println();
        }

    }

/*    public int data1 = 1;
    //--------
//    public OuterClass.InnerClass a;
    //--------
    private int data2 = 2;
    public static int data3 = 3;

    public void func() {
        System.out.println("Out-func");
    }

    class InnerClass {
        public int data4 = 10;
        public int data5 = 10;
        public int data6 = 10;

        public void func() {
            System.out.println("Inner-func");
        }
    }*/

}

public class Test1 {

    public static void main(String[] args) {
        OuterClass.InnerClass innerClass = new OuterClass.InnerClass();
    }

/*    public static void main(String[] args) {
        OuterClass out = new OuterClass();
        OuterClass.InnerClass inner = out.new InnerClass();
    }

    public static void main1(String[] args) {


//        OuterClass.InnerClass inner1 = new OuterClass().a;

        OuterClass out = new OuterClass();
        OuterClass.InnerClass inner2 = out.new InnerClass();

        OuterClass.InnerClass inner3 = new OuterClass().new InnerClass();

//        inner1.func();
        inner2.func();
        inner3.func();


    }*/
}
